package com.steven.download.download.db.room;

import com.steven.download.download.db.DownloadEntity;

import java.util.List;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

/**
 * @Des:
 * @Author: hwz
 * @Date:2021/11/10 0010
 * @Version: 1.0
 */
@Dao
public interface DownloadDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(DownloadEntity... books);

    @Update
    void update(DownloadEntity... books);

    @Delete
    void delete(DownloadEntity... books);

    @Query("SELECT * FROM download")
    List<DownloadEntity> queryAll();

    @Query("DELETE FROM download WHERE packageUrl IN(:packageUrl)")
    void deleteByUrl(String packageUrl);


    @Query("SELECT * FROM download WHERE packageUrl IN(:packageUrl)")
    List<DownloadEntity> queryDownloadByUrl(String packageUrl);
}
